package com.yanqu.road.entity.activity.fund;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_u_activity_fund", desc = "通用的活动基金/战令")
public class UserActivityFundData extends DataObject {
    @FieldTypeAnnotation(select = true, update = true, desc = "活动id")
    private int activityId;
    @FieldTypeAnnotation(select = true, update = true, desc = "用户id")
    private long userId;
    @FieldTypeAnnotation(desc = "已购买的mall索引,对应mallInfo的extendParam")
    private List<Integer> buyMallKeyIds = new ArrayList<>();
    @FieldTypeAnnotation(desc = "进度")
    private long progress;

    public UserActivityFundData() {
    }

    public UserActivityFundData(int activityId, long userId) {
        this.activityId = activityId;
        this.userId = userId;
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public List<Integer> getBuyMallKeyIds() {
        return buyMallKeyIds;
    }

    public void setBuyMallKeyIds(List<Integer> buyMallKeyIds) {
        this.buyMallKeyIds = buyMallKeyIds;
        setUpdateOption();
    }

    public long getProgress() {
        return progress;
    }

    public void setProgress(long progress) {
        this.progress = progress;
        setUpdateOption();
    }

    public void addProgress(long addValue) {
        this.progress += addValue;
        setUpdateOption();
    }

    public void addBuyMallKeyIds(int mallKeyId) {
        this.buyMallKeyIds.add(mallKeyId);
        setUpdateOption();
    }

    public boolean isBuyByMallKey(int mallKeyId) {
        return this.buyMallKeyIds.contains(mallKeyId);
    }
}
